package com.sikaryofficial.backend.config;

import cn.hutool.core.text.CharSequenceUtil;
import lombok.Getter;
import lombok.Setter;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * Minio 配置信息
 *
 * @author qinjinyuan
 */
@Setter
@Getter
@Component
public class MinioConfig  implements InitializingBean
{
    /**
     * Minio服务地址
     */
    public static String minioServiceUrl;

    @Value("${minio.minioServiceUrl}")
    public String minioServiceUrlTmp;

    /**
     * 初始化配置信息
     */
    @Override
    public void afterPropertiesSet() {
        minioServiceUrl = this.minioServiceUrlTmp;
    }

    /**
     * 获取完整路径
     *
     * @param innerUrl
     * @return
     */
    public static String getUrlPrefix(String innerUrl) {
        if (CharSequenceUtil.isBlank(innerUrl)) {
            return innerUrl;
        }
        return minioServiceUrl.concat(innerUrl);
    }
}
